<template>
    <van-sticky>
        <van-nav-bar title="列表" left-text="返回" left-arrow @click-left="onClickLeft" />
    </van-sticky>
    <van-card v-for="item in search" :key="item.goods_id" :price="item.goods_price" :title="item.goods_name"
        :thumb="item.goods_small_logo" @click="disnji(item.goods_id)"/>

</template>
<script setup>
import axios from 'axios';
import { ref } from 'vue';
const onClickLeft = () => history.back();
import { useRouter, useRoute } from 'vue-router';
const router = new useRouter();
const route = new useRoute();

const search = ref([]);
axios.get("https://api-hmugo-web.itheima.net/api/public/v1/goods/search", {
    params: {
        cid: route.query.cid
    }
}).then(res => {
    search.value = res.data.message.goods
})

const disnji=(goods_id)=>{
    router.push({
        path:'/detail',
        query:{
            goods_id
        }
    })
}
</script>

<style lang="scss" scoped></style>